home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / gridex / frmsort.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-01-02  |  9.9 KB  |  317 lines

  1. VERSION 5.00
  2. Begin VB.Form frmSort 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Sort"
  5.    ClientHeight    =   4680
  6.    ClientLeft      =   2070
  7.    ClientTop       =   2475
  8.    ClientWidth     =   6015
  9.    Icon            =   "frmSort.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   312
  14.    ScaleMode       =   3  'Pixel
  15.    ScaleWidth      =   401
  16.    ShowInTaskbar   =   0   'False
  17.    StartUpPosition =   2  'CenterScreen
  18.    Begin VB.CommandButton cmdClearAll 
  19.       Caption         =   "Clear All"
  20.       Height          =   330
  21.       Left            =   4740
  22.       TabIndex        =   18
  23.       Top             =   1020
  24.       Width           =   1200
  25.    End
  26.    Begin VB.CommandButton cmdCancel 
  27.       Cancel          =   -1  'True
  28.       Caption         =   "Cancel"
  29.       Height          =   330
  30.       Left            =   4740
  31.       TabIndex        =   17
  32.       Top             =   630
  33.       Width           =   1200
  34.    End
  35.    Begin VB.CommandButton cmdOK 
  36.       Caption         =   "OK"
  37.       Default         =   -1  'True
  38.       Height          =   330
  39.       Left            =   4740
  40.       TabIndex        =   16
  41.       Top             =   240
  42.       Width           =   1200
  43.    End
  44.    Begin VB.Frame Frame1 
  45.       Caption         =   "Then by"
  46.       Height          =   1005
  47.       Index           =   3
  48.       Left            =   120
  49.       TabIndex        =   12
  50.       Top             =   3555
  51.       Width           =   4290
  52.       Begin VB.OptionButton optOrder 
  53.          Caption         =   "Descending"
  54.          Enabled         =   0   'False
  55.          Height          =   255
  56.          Index           =   7
  57.          Left            =   2800
  58.          TabIndex        =   15
  59.          Top             =   555
  60.          Width           =   1320
  61.       End
  62.       Begin VB.OptionButton optOrder 
  63.          Caption         =   "Ascending"
  64.          Enabled         =   0   'False
  65.          Height          =   255
  66.          Index           =   6
  67.          Left            =   2800
  68.          TabIndex        =   14
  69.          Top             =   225
  70.          Value           =   -1  'True
  71.          Width           =   1320
  72.       End
  73.       Begin VB.ComboBox cboGroups 
  74.          Enabled         =   0   'False
  75.          Height          =   315
  76.          Index           =   3
  77.          Left            =   135
  78.          Style           =   2  'Dropdown List
  79.          TabIndex        =   13
  80.          Top             =   285
  81.          Width           =   2595
  82.       End
  83.    End
  84.    Begin VB.Frame Frame1 
  85.       Caption         =   "Then by"
  86.       Height          =   1005
  87.       Index           =   2
  88.       Left            =   120
  89.       TabIndex        =   8
  90.       Top             =   2420
  91.       Width           =   4290
  92.       Begin VB.OptionButton optOrder 
  93.          Caption         =   "Descending"
  94.          Enabled         =   0   'False
  95.          Height          =   255
  96.          Index           =   5
  97.          Left            =   2800
  98.          TabIndex        =   11
  99.          Top             =   555
  100.          Width           =   1320
  101.       End
  102.       Begin VB.OptionButton optOrder 
  103.          Caption         =   "Ascending"
  104.          Enabled         =   0   'False
  105.          Height          =   255
  106.          Index           =   4
  107.          Left            =   2820
  108.          TabIndex        =   10
  109.          Top             =   225
  110.          Value           =   -1  'True
  111.          Width           =   1320
  112.       End
  113.       Begin VB.ComboBox cboGroups 
  114.          Enabled         =   0   'False
  115.          Height          =   315
  116.          Index           =   2
  117.          Left            =   135
  118.          Style           =   2  'Dropdown List
  119.          TabIndex        =   9
  120.          Top             =   285
  121.          Width           =   2595
  122.       End
  123.    End
  124.    Begin VB.Frame Frame1 
  125.       Caption         =   "Then by"
  126.       Height          =   1005
  127.       Index           =   1
  128.       Left            =   120
  129.       TabIndex        =   4
  130.       Top             =   1285
  131.       Width           =   4290
  132.       Begin VB.ComboBox cboGroups 
  133.          Enabled         =   0   'False
  134.          Height          =   315
  135.          Index           =   1
  136.          Left            =   135
  137.          Style           =   2  'Dropdown List
  138.          TabIndex        =   7
  139.          Top             =   285
  140.          Width           =   2595
  141.       End
  142.       Begin VB.OptionButton optOrder 
  143.          Caption         =   "Ascending"
  144.          Enabled         =   0   'False
  145.          Height          =   255
  146.          Index           =   2
  147.          Left            =   2800
  148.          TabIndex        =   6
  149.          Top             =   225
  150.          Value           =   -1  'True
  151.          Width           =   1320
  152.       End
  153.       Begin VB.OptionButton optOrder 
  154.          Caption         =   "Descending"
  155.          Enabled         =   0   'False
  156.          Height          =   255
  157.          Index           =   3
  158.          Left            =   2790
  159.          TabIndex        =   5
  160.          Top             =   555
  161.          Width           =   1320
  162.       End
  163.    End
  164.    Begin VB.Frame Frame1 
  165.       Caption         =   "Sort Items by"
  166.       Height          =   1005
  167.       Index           =   0
  168.       Left            =   120
  169.       TabIndex        =   0
  170.       Top             =   150
  171.       Width           =   4290
  172.       Begin VB.OptionButton optOrder 
  173.          Caption         =   "Descending"
  174.          Enabled         =   0   'False
  175.          Height          =   255
  176.          Index           =   1
  177.          Left            =   2800
  178.          TabIndex        =   3
  179.          Top             =   555
  180.          Width           =   1320
  181.       End
  182.       Begin VB.OptionButton optOrder 
  183.          Caption         =   "Ascending"
  184.          Enabled         =   0   'False
  185.          Height          =   255
  186.          Index           =   0
  187.          Left            =   2800
  188.          TabIndex        =   2
  189.          Top             =   225
  190.          Value           =   -1  'True
  191.          Width           =   1320
  192.       End
  193.       Begin VB.ComboBox cboGroups 
  194.          Height          =   315
  195.          Index           =   0
  196.          Left            =   135
  197.          Style           =   2  'Dropdown List
  198.          TabIndex        =   1
  199.          Top             =   285
  200.          Width           =   2595
  201.       End
  202.    End
  203. Attribute VB_Name = "frmSort"
  204. Attribute VB_GlobalNameSpace = False
  205. Attribute VB_Creatable = False
  206. Attribute VB_PredeclaredId = True
  207. Attribute VB_Exposed = False
  208. Option Explicit
  209. Dim mAceptado As Boolean
  210. Private Sub cboGroups_Click(Index As Integer)
  211.     If cboGroups(Index).ListIndex = 0 Then
  212.         optOrder(Index * 2).Enabled = False
  213.         optOrder(Index * 2 + 1).Enabled = False
  214.         optOrder(Index * 2).Value = True
  215.         If Index < 3 Then
  216.             cboGroups(Index + 1).ListIndex = 0
  217.             cboGroups(Index + 1).Enabled = False
  218.         End If
  219.     Else
  220.         optOrder(Index * 2).Enabled = True
  221.         optOrder(Index * 2 + 1).Enabled = True
  222.         optOrder(Index * 2).Value = True
  223.         If Index < 3 Then
  224.             cboGroups(Index + 1).Enabled = True
  225.         End If
  226.     End If
  227. End Sub
  228. Public Sub SortGrid(grid As GridEX)
  229. Dim cs As Columns
  230. Dim c As Column
  231. Dim i As Integer
  232. Dim j As Integer
  233. Dim gr As JSGridEX.SortKey
  234. Dim grs As JSGridEX.SortKeys
  235.     For j = 0 To 3
  236.         cboGroups(j).AddItem "(None)"
  237.     Next
  238.     Set cs = grid.Columns
  239.     For i = 1 To cs.Count
  240.         Set c = cs.Item(i)
  241.         For j = 0 To 3
  242.             cboGroups(j).AddItem c.Tag
  243.             cboGroups(j).ItemData(cboGroups(j).NewIndex) = c.Index
  244.         Next
  245.     Next i
  246.     cboGroups(0).ListIndex = 0
  247.     For i = 1 To grid.SortKeys.Count
  248.         Set gr = grid.SortKeys.Item(i)
  249.         cboGroups(i - 1).Text = cs.Item(gr.ColIndex).Caption
  250.         If gr.SortOrder = 1 Then
  251.             optOrder((i - 1) * 2).Value = True
  252.         Else
  253.             optOrder((i - 1) * 2 + 1).Value = True
  254.         End If
  255.     Next i
  256.     mAceptado = False
  257.     Show 1
  258.     Dim Changes As Boolean
  259.     Set grs = grid.SortKeys
  260.     If mAceptado Then
  261.         For i = 0 To 3
  262.             If cboGroups(i).ListIndex = 0 Then
  263.                 If grs.Count > i Then
  264.                     Changes = True
  265.                     Exit For
  266.                 End If
  267.             Else
  268.                 If grs.Count >= i + 1 Then
  269.                     Set gr = grs.Item(i + 1)
  270.                     If gr.ColIndex <> cboGroups(i).ItemData(cboGroups(i).ListIndex) Then
  271.                         Changes = True
  272.                         Exit For
  273.                     Else
  274.                         If optOrder(i * 2).Value Then
  275.                             If gr.SortOrder <> 1 Then
  276.                                 Changes = True
  277.                                 Exit For
  278.                             End If
  279.                         Else
  280.                             If gr.SortOrder <> -1 Then
  281.                                 Changes = True
  282.                                 Exit For
  283.                             End If
  284.                         End If
  285.                     End If
  286.                 Else
  287.                     Changes = True
  288.                     Exit For
  289.                 End If
  290.             End If
  291.         Next
  292.     End If
  293.     If Changes Then
  294.         Screen.MousePointer = 11
  295.       '  grid.Parent.Refresh
  296.         grs.Clear
  297.         For i = 0 To 3
  298.             If cboGroups(i).ListIndex <> 0 Then
  299.                 grs.Add cboGroups(i).ItemData(cboGroups(i).ListIndex), IIf(optOrder(i * 2), 1, -1)
  300.             End If
  301.         Next
  302.         grid.RefreshSort
  303.         Screen.MousePointer = 0
  304.     End If
  305.     Unload Me
  306. End Sub
  307. Private Sub cmdCancel_Click()
  308.     Hide
  309. End Sub
  310. Private Sub cmdClearAll_Click()
  311.     cboGroups(0).ListIndex = 0
  312. End Sub
  313. Private Sub cmdOK_Click()
  314.     mAceptado = True
  315.     Hide
  316. End Sub
  317.